<?php

namespace App\Http\Controllers\Admin\Member;

use App\Http\Controllers\Controller;

use App\Models\MemberRight;
use App\Traits\Controllers\AdminTraits;
use App\Traits\Controllers\UpdateStatusTraits;
use App\Transformers\Member\MemberRightTransFormer;
use Illuminate\Http\Request;

class MemberRightController extends Controller
{
   /**
    * 会员权益表 增删改查
    *
    */
   use AdminTraits;
   use UpdateStatusTraits;

   public $model =MemberRight::class;

   public $transformer = MemberRightTransFormer::class;


    /**
     * 参数验证规则
     *
     * @param Request $request
     * @return array
     */
    public function rules(Request $request): array
    {
        switch ($request->method()) {
            case 'GET':
                return [];
                break;
            case 'POST':
            case 'PUT':
            case 'PATCH':
                return [
                    'right_type'=>'required|max:32',
                    'right_title'=>'required|max:255',
                    'show_title'=>'required|exists:member_rights,right_type',
                    'image'=>'required|mimes:jpeg,jpg,png,jif',
                    'explain'=>'required|max:255',
                    'number'=>'required',
                    'sort'=>'required',

                ];
                break;

        }
        return [];
    }

    /**
     * 验证信息
     *
     * @return array
     */
    public function ruleMessages(): array
    {
        return [
            'right_type.required'=>'权益类型不能为空',
            'right_type.max'=>'权益类型',
            'right_title.required'=>'权益名称不能为空',
            'show_title.required'=>' 显示权益不能空',
            'show_title.exists'=>' 显示权益不存在',
            'image.required'=>'图片不能为空',
            'image.mimes'=>'图片类型不合法',
            'explain.required'=>'权益介绍不能空',
            'explain.max'=>'权益介绍不能超过255个字符',
            'number'=>'规则数字不能为空',
            'sort.required'=>'排序不能为空',
        ];
    }
}
